<!---
    Title:      Admin page for APT Duty Roster
    Author:     Bruce Frick
    Purpose:    Setting the day's Roster for APT per clinic
--->

<cfset BASE = CreateObject("component", "SharePointModules.apt.cfc.base") />
<cfset QUERIES = CreateObject("component", "SharePointModules.apt.cfc.queries") />

<cfparam default="#dateFormat(now(), 'mm/dd/yyyy')#" name="url.date" />
<cfparam default="_AKA-PC 3 West" name="url.clinic" />

<cfset clinics['_AKA-PC 1 East'] = 'PCC 1E ' />
<cfset clinics['_AKA-PC 2 East'] = 'PCC 2E ' />
<cfset clinics['_AKA-PC 3 East'] = 'PCC 3E ' />
<cfset clinics['_AKA-PC 1 West'] = 'PCC 1W ' />
<cfset clinics['_AKA-PC 2 West'] = 'PCC 2W ' />
<cfset clinics['_AKA-PC 3 West'] = 'PCC 3W ' /> 


<cfoutput>
<!---HTML header, css links, js links, and page title--->
#BASE.htmlHeader(
    "/jquery/jquery-1.4.2.min.js,/jquery/ui-1.8.5/jquery-ui.min.js,
       /tiny_mce/jquery.tinymce.js,
       /tiny_mce/tiny_mce.js,/jquery/js/jquery.tablesorter.min.js,
       ../apt/js/admin.js",  
    "/jquery/ui-1.8.5/themes/base/jquery-ui.css", 
    clinics[url.clinic] & " " & url.date & " Roster" & " Admin Roster")#
<!---HTML header, css links, js links, and page title--->

<cfform id="myform" >

<cfset PROVIDERS_GROUP = "CN=" & #url.clinic# & 
    " Providers,OU=Groups,OU=SCF,OU=SCFUsers,DC=SouthcentralFoundation,DC=com" />

<cfset ProvidersArray = BASE.SCF_Exchange_GetEmployeesInDL(PROVIDERS_GROUP) />

<cfset caseMgrsArray = BASE.SCF_Exchange_GetEmployeesInDL(
    "CN=_AKA-PC Case Managers,OU=Groups,OU=SCF,OU=SCFUsers,DC=SouthcentralFoundation,DC=com") />
    
<cfset cmaLpnArray = BASE.SCF_Exchange_GetEmployeesInDL(
    "CN=_AKA-PC CMA_LPN,OU=Groups,OU=SCF,OU=SCFUsers,DC=SouthcentralFoundation,DC=com")/>
    
<cfset cmsArray = BASE.SCF_Exchange_GetEmployeesInDL(
    "CN=_AKA-PC CMS,OU=Groups,OU=SCF,OU=SCFUsers,DC=SouthcentralFoundation,DC=com")/>   


<!---  Pull all user added staff support to display in dropdowns--->
<cfset addedCMA = QUERIES.FuncQryGetRoster("CMA-LPN") />
<cfset addedCMS = QUERIES.FuncQryGetRoster("CMS") />
<cfset addedCaseManagers = QUERIES.FuncQryGetRoster("Case Managers") />
<cfset addedProvider = QUERIES.FuncQryGetRoster("Provider") />

<h2>APT Roster</h2>
<h2> #clinics[url.clinic]#  
    <cfinput type="text" name="choose_roster_date" value="#url.date#" size="15"/>
</h2>


<table width="99%" class="apt">
    <tbody>
        <tr id="data_input">
            <td>
                <div>Providers</div>
                <cfselect name="providers" >
                <cfloop from="1" to="#ArrayLen(ProvidersArray)#" index="i">
                    <cfif ProvidersArray[i].RosettaID neq 0>
                        <option value="#ProvidersArray[i].RosettaID#">
                            #trim(ProvidersArray[i].LastName)#, #ProvidersArray[i].FirstName#
                         </option>
                    </cfif>
                </cfloop>
                <cfloop query="addedProvider">
                    <option value="88888#AddedID#">
                           #QUERIES.FuncQryGetAddedStaffByID(AddedID)#
                    </option>
                </cfloop>
                </cfselect>
            </td>
            <td>                
                <div>Resource Code</div>
                <cfinput name="resource_code" size="15"/>
            </td>
            <td>                   
                <div>Title</div>
                <cfinput name="title" size="15"/>
            </td>
            <td>                   
                <div>Shift</div>
                <cfinput name="the_shift" size="15"/>
            </td>
            <td>                   
                <div>Case Managers</div>
                <cfselect name="case_mgrs" >
                <option value="-2">NA</option>
                <option value="-3"> </option>
                <cfloop from="1" to="#ArrayLen(caseMgrsArray)#" index="i">
                    <cfif caseMgrsArray[i].RosettaID neq 0>
                        <option value="#caseMgrsArray[i].RosettaID#">
                            #trim(caseMgrsArray[i].LastName)#, #caseMgrsArray[i].FirstName#
                        </option>
                    </cfif>
                </cfloop>
                <cfloop query="addedCaseManagers">
                    <option value="88888#AddedID#">
                        #QUERIES.FuncQryGetAddedStaffByID(AddedID)#
                    </option>
                </cfloop>
                </cfselect>
            </td>
            
            <td>                   
                <div>CM Support</div>
                <cfselect name="cms_support">
                <option value="-2">NA</option>
                <option value="-3"> </option>
                <cfloop from="1" to="#ArrayLen(cmsArray)#" index="i">
                    <cfif cmsArray[i].RosettaID neq 0>
                        <option value="#cmsArray[i].RosettaID#">
                            #trim(cmsArray[i].LastName)#, #cmsArray[i].FirstName#
                        </option>
                    </cfif>
                </cfloop>
                <cfloop query="addedCMS">
                    <option value="88888#AddedID#">
                        #QUERIES.FuncQryGetAddedStaffByID(AddedID)#
                    </option>
                </cfloop>
                </cfselect>
            </td>
            <td>                   
                <div>CMA / LPN</div>
                <cfselect name="cma_lpn">
                <option value="-2">NA</option>
                <option value="-3"> </option>
                <cfloop from="1" to="#ArrayLen(cmaLpnArray)#" index="i">
                    <cfif cmaLpnArray[i].RosettaID neq 0>
                        <option value="#cmaLpnArray[i].RosettaID#">
                            #trim(cmaLpnArray[i].LastName)#, #cmaLpnArray[i].FirstName#
                        </option>
                    </cfif>
                </cfloop>
                <cfloop query="addedCMA">
                    <option value="88888#AddedID#">
                        #QUERIES.FuncQryGetAddedStaffByID(AddedID)#
                    </option>
                </cfloop>
                </cfselect>
            </td>
            <td>                   
                <div>Notes</div>
                <cfinput name="notes" size="30"/>

            </td>
        </tr>
        <tr>
            <td colspan="8">
                <cfinput type="button" name="insert_row" value="Add To Roster" />
            </td>
        </tr>
        <tr>
            <td colspan="8">&nbsp;</td>
        </tr>
        <tr>
            <td colspan="8">
                <div>Special Instructions</div>
                <textarea id="special_instructions" cols="175" rows="8" 
                    class="tinymce" >
                        #QUERIES.FuncQrySelectSpecialInstructions(url.clinic, url.date).SpecialInstructions#
                </textarea>
            </td>
        </tr>
        <tr>
            <td colspan="8">&nbsp;</td>
        </tr>
    </tbody>
    <tfoot>     
        <tr>
            <td colspan="8">
                
                <cfinput type="button" name="publish" value="Publish Roster" /> For
                <cfinput type="text" name="publish_date" value="#dateFormat(now(), 'mm/dd/yyyy')#" size="10"/>
                <a href="view.cfm">View Roster</a>
                <a href="add.cfm">Add to Roster</a>
                <cfinput type="hidden" name="roster_date" value="#dateFormat(now(), 'mm/dd/yyyy')#" />
                <cfinput type="hidden" name="clinic" value="#url.clinic#" />
            </td>
        </tr>   
    </tfoot>
</table>
<br />

<table id="roster" border="0" cellpadding="0" cellspacing="0" width="100%">
<thead>
    <tr>
        <th width="1%">&nbsp;</th>
        <th>Provider</th><th>Resource Code</th>
        <th>Title</th><th>Shift</th><th>Case Manager</th><th>CM Support</th>
        <th>CMA</th><th>Notes</th>
    </tr>
</thead>
<tbody id="roster_rows">
    <cfset counter = 0 />
    <cfset Roster = QUERIES.FuncQrySelectRoster(url.clinic, url.date) />
    <cfloop query="Roster">
        <cfset counter = counter + 1 />
        <tr id="row_#counter#">
            <td><input type="button" id="rowdb_#AptID#" value="Delete" /> &nbsp;</td>
            <td><input type="hidden"  value="#ProviderID#" /> #BASE.funcFindAddedStaffName(ProviderID)# &nbsp;</td>
            <td><input type="hidden"  value="#ResourceCode#" /> #ResourceCode# &nbsp;</td>
            <td><input type="hidden"  value="#Title#" /> #Title# &nbsp;</td>
            <td><input type="hidden"  value="#Shift#" /> #Shift# &nbsp;</td>
            <td><input type="hidden"  value="#CaseManagerID#" /> #BASE.funcFindAddedStaffName(CaseManagerID)# &nbsp;</td>
            <td><input type="hidden"  value="#CMSSupportID#" /> #BASE.funcFindAddedStaffName(CMSSupportID)# &nbsp;</td>
            <td><input type="hidden"  value="#CMAID#" /> #BASE.funcFindAddedStaffName(CMAID)# &nbsp;</td>
            <td><input type="hidden"  value="#Notes#" /> #Notes# &nbsp;</td>
        </tr>
    </cfloop>
</tbody>
</table>

</cfform>
<!---HTML footer, closes html and body tags.  Any footer info goes here--->
#BASE.htmlFooter()#
<!---HTML footer, closes html and body tags.  Any footer info goes here--->
</cfoutput>